import requests
import chardet

# http_header = {
#     'User-Agent':'Mozilla/5.0',
# }
r = requests.get("https://www.baidu.com")
# print(r.content)
cs = chardet.detect(r.content)
r.encoding = cs['encoding']
print(r.text[0:500])